<?php
/*
 * zhi bo
 * */
namespace app\index\controller;
use think\Controller;

class ZhiBo extends Controller
{
    protected $true = 0;
    protected $allMan;
    public function index()
    {
        $this->fetch("index");
    }
    public function getInfo()
    {
        if ($_POST['id'] == 1)
        {
            if($this->true == 0)
            {
                echo $this->initMan();
            }
            else
            {
                $this->hotAdd();
            }
        }
        else
        {
            $this->hotDec();
        }
    }
    public function nobody()
    {
        $this->randAdd();
    }
    public function initMan()
    {
        $first = $this->getTure();
        $this->allMan = $first  + rand(1000,1500);
        //echo $this->allMan;
    }
    public function getTure()
    {
        $this->true += 1;
        return $this->true;
    }
    public function hotAdd()
    {
        $randMan = rand(2,5);
        $this->allMan += ($this->getTure() * $randMan);
        echo $this->allMan;
    }
    public function hotDec()
    {
        $randMan = rand(1,3);
        $this->allMan -= (($this->true - 1) * $randMan);
        $this->true -= 1;
        echo '<br>';
        echo $this->allMan;
    }
    public function randAdd()
    {
        while(1)
        {
            $ranMan = rand(-5,10);
            $this->allMan += $ranMan;
            if ($this->allMan <= 1000)
            {
                $this->allMan = 1000;
            }
            echo $this->allMan;
        }
    }
}